CFLAGS=-Wall
LDFLAGS=
CC=gcc
TOOLS=dumpconfig.exe getconfig.exe putconfig.exe mkconfig.exe getlog.exe loginfo.exe dumplog.exe plotlog.exe statistics.exe

.SUFFIXES: .exe

compile: ${TOOLS}
dumpconfig.exe: dumpconfig.o util.o obd_pid.o
getconfig.exe: getconfig.o util.o serial.o obd_pid.o
putconfig.exe: putconfig.o util.o serial.o obd_pid.o
mkconfig.exe: mkconfig.o util.o obd_pid.o
getlog.exe: getlog.o util.o serial.o obd_pid.o progress.o
loginfo.exe: loginfo.o util.o obd_pid.o
statistics.exe: statistics.o util.o obd_pid.o
	${CC} -o ${@} ${^} ${LDFLAGS} -lws2_32
dumplog.exe: dumplog.o util.o obd_pid.o
	${CC} -o ${@} ${^} ${LDFLAGS} -lws2_32
plotlog.exe: plotlog.o util.o obd_pid.o
	${CC} -o ${@} ${^} ${LDFLAGS} -lws2_32


util.o: util.c obd_pid.c
serial.o: serial.c
dumpconfig.o: dumpconfig.c
getconfig.o: getconfig.c
putconfig.o: putconfig.c
mkconfig.o: mkconfig.c
getlog.o: getlog.c
loginfo.o: loginfo.c
dumplog.o: dumplog.c
obd_pid.o: obd_pid.c
plotlog.o: plotlog.c
statistics.o: statistics.c
progress.o: progress.c

.c.o:
	${CC} -c ${<} ${CFLAGS}

.o.exe:
	${CC} -o ${@} ${^} ${LDFLAGS}

clean:
	rm -f ${TOOLS} *.core *.o
